package com.zoe.app;

import com.zoe.app.entity.Animal;
import com.zoe.app.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Zoe.Zhang
 * @Date: 2021/09/21
 * @Description 属性注入
 */
@SpringBootApplication
@RestController
public class MainAppFileZhuRu {
    public static void main(String[] args) {
        SpringApplication.run(MainAppFileZhuRu.class, args);
    }

    @Autowired
    ApplicationContext applicationContext;

    @GetMapping("/")
    public String hello() {
        return applicationContext.getBean(Animal.class).toString() + " \n" + applicationContext.getBean(Book.class)
                                                                                               .toString();
    }
}
